package com.pokeoffice.server;

import com.pokeoffice.interfaces.Command;

/**
 * The Class Router.
 *
 * @author Kyle Davis
 * 
 * (Pattern: Router, Singleton)
 */
public class Router {

	/** The router. */
	private static Router router = null;
	
	/** The command queue. */
	private CommandQueue commandQueue = null;
	
	/**
	 * Instantiates a new router.
	 */
	private Router() {
		commandQueue = new CommandQueue();
	}
	
	/**
	 * Gets the.
	 *
	 * @return the router
	 */
	public static synchronized Router get() {
		if (router == null) {
			router = new Router();
		}
		
		return router;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#clone()
	 */
	public Object clone() throws CloneNotSupportedException {
		throw new CloneNotSupportedException();
	}
	
	/**
	 * Route.
	 *
	 * @param com the com
	 */
	public void route(Command com) {
		// TODO pass off to handler, for now throw on a generic commandqueue
		commandQueue.put(com);
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "Router: "; 
	}

}
